package com.cn.xiaonuo.tcrfinance.tcrorder.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.common.constant.Status;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.common.utils.DateUtils;
import com.cn.xiaonuo.common.utils.OrderNumGeneration;
import com.cn.xiaonuo.core.factory.PageFactory;
import com.cn.xiaonuo.tcrfinance.tcrorder.entity.*;
import com.cn.xiaonuo.tcrfinance.tcrorder.mapper.*;
import com.cn.xiaonuo.tcrfinance.tcrorder.param.PvBuySellOrderParam;
import com.cn.xiaonuo.tcrfinance.tcrorder.param.PvOrderParam;
import com.cn.xiaonuo.tcrfinance.tcrorder.service.PvOrderService;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.PvProduct;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.PvProductGl;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PlatformMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PvProductGlMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PvProductMapper;
import com.cn.xiaonuo.tcrfinance.sysmgmt.entity.PvSystemConfig;
import com.cn.xiaonuo.tcrfinance.sysmgmt.mapper.PvSystemConfigMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;

@Service
public class PvOrderServiceImpl extends ServiceImpl<PvOrderMapper, PvOrder> implements PvOrderService {

    private static final Logger log = LoggerFactory.getLogger(PvOrderServiceImpl.class);
    private static String transferableTimeGetHolidayRedisKey = "transferableTimeGetHolidayRedisKey";

    @Autowired
    private PvProductGlMapper pvProductGlMapper;
    @Autowired
    private PvOrderMapper pvOrderMapper;
    @Autowired
    private PvProductMapper pvProductMapper;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private PvSystemConfigMapper pvSystemConfigMapper;
    @Autowired
    private PvPossessionGoodsMapper pvPossessionGoodsMapper;
    @Autowired
    private PvPossessionGoodsLogMapper pvPossessionGoodsLogMapper;
    @Autowired
    private PvReleaseBaseMapper pvReleaseBaseMapper;
    @Autowired
    private PvHolidayMapper pvHolidayMapper;
    @Autowired
    private PlatformMapper patformMapper;
    @Autowired
    private PvTicketingRecordMapper pvTicketingRecordMapper;


    @Override
    public PageInfo<Map<String, Object>> queryHtProductList(Map<String, Object> params) {
        // 设置分页参数
        //Page page= PageFactory.defaultPage();
        Integer pageSize = (Integer) params.get("pageSize");
        Integer pageNo = (Integer) params.get("pageNo");
        if (null == pageNo || Integer.valueOf(pageNo) <= 1) {
            pageNo = 1;
        }
        if (null == pageSize || Integer.valueOf(pageSize) <= 1) {
            pageSize = 30;
        }
        PageHelper.startPage(pageNo, pageSize);
        String pickProductId = Convert.toStr(params.get("pickProductId"));
        List<String> pickProductIdList = null;
        if (org.apache.commons.lang3.StringUtils.isNotBlank(pickProductId)) {
            String[] pickProductIds = pickProductId.split(",");
            pickProductIdList = Arrays.asList(pickProductIds);
        }
        // 设置分页参数
        List<Map<String, Object>> lists = pvOrderMapper.queryHtProductList(pickProductIdList);
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(lists);
        return pageInfo;

    }

    /**
     * 上票
     */
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public synchronized BusinessMessage ticketUp(PvOrderParam pvOrderParam ) {
        SimpleDateFormat ymd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        PvOrder order=new PvOrder();
        BeanUtil.copyProperties(pvOrderParam,order);
        BusinessMessage<Object> message = new BusinessMessage<>();
        try {
            if (order.getDelistingNumber() <= 0) {
                message.setCode("-1");
                message.setSuccess(false);
                message.setMessage("请输入正确的数量");
                return message;
            }
            if (StringUtils.isBlank(order.getProductId().toString())) {
                message.setSuccess(false);
                message.setCode("-1");
                message.setMessage("商品ID不能为空");
                return message;
            }
            PvProduct pvProduct = pvProductMapper.selectById(order.getProductId());
            PvProductGl pvProductGl = pvProductGlMapper.selectOne(new QueryWrapper<>(new PvProductGl(){{
                setShopId(pvProduct.getShopId());
            }}));
            if (pvProductGl == null) {
                message.setSuccess(false);
                message.setCode("-1");
                message.setMessage("没有查询到对应账号");
                return message;
            }
            if (pvProduct == null) {
                message.setSuccess(false);
                message.setCode("-1");
                message.setMessage("没有查询到该商品");
                return message;
            }
            order.setProductName(pvProduct.getName());
            order.setRemark("上传商品数量");
            order.setPaymentState(1);
            order.setUnitPrice(BigDecimal.valueOf(0));
            //TODO 生成上票订单
            Integer buyorderid = this.productOrder(order, BigDecimal.valueOf(0), 1, BigDecimal.valueOf(order.getDelistingNumber()));
            //TODO 释放表计算数据:买入订单
            addReleaeseBase(buyorderid, pvProductGl.getSellUserId(), order.getProductId(), order.getDelistingNumber(), order.getUnitPrice(), 7, 2, BigDecimal.valueOf(0));
            //上票
            LambdaQueryWrapper<PvPossessionGoods> possGoodsCon=new LambdaQueryWrapper<>();
            possGoodsCon.eq(PvPossessionGoods::getProductId,order.getProductId());
            possGoodsCon.eq(PvPossessionGoods::getUserId,pvProductGl.getSellUserId());
            PvPossessionGoods pvPossessionGoods = pvPossessionGoodsMapper.selectOne(possGoodsCon);
            String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            if (pvPossessionGoods == null) {
                //如果没有用该商品信息
                pvPossessionGoods = new PvPossessionGoods();
                //摘单用户ID
                pvPossessionGoods.setUserId(pvProductGl.getSellUserId());
                //摘单的商品ID
                pvPossessionGoods.setProductId(order.getProductId());
                //摘单数量
                pvPossessionGoods.setCansellNumber(new BigDecimal(order.getDelistingNumber()));
                //摘单商品名称
                pvPossessionGoods.setProductName(order.getProductName());
                pvPossessionGoods.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
                pvPossessionGoods.setUpdatedAt(new Date());
                int i = pvPossessionGoodsMapper.insert(pvPossessionGoods);
                //商品数量变化日志
                this.goodsNumLog(order, pvPossessionGoods, buyorderid, 1);
            } else {
                PvTicketingRecord ticketData= pvPossessionGoodsMapper.queryGoodsDetail(pvProduct.getId());
                PvTicketingRecord pvTicketingRecord = new PvTicketingRecord();
                BeanUtils.copyProperties(ticketData,pvTicketingRecord);
                pvTicketingRecord.setBeforeNumber(pvPossessionGoods.getCansellNumber());
                pvTicketingRecord.setChangeNumber(pvOrderParam.getDelistingNumber());
                pvTicketingRecord.setAfterNumber(Convert.toBigDecimal(pvOrderParam.getDelistingNumber()).add(pvPossessionGoods.getCansellNumber()));
                pvTicketingRecord.setOperator(pvOrderParam.getOperator());
                pvTicketingRecord.setOperatorId(pvOrderParam.getOperatorId());
                pvTicketingRecord.setCreateTime(ymd.format(new Date()));
                pvTicketingRecord.setUpdateTime(ymd.format(new Date()));
                pvTicketingRecordMapper.insert(pvTicketingRecord);
                //添加商品变化日志
                // type=1冻结量加
                // type=2冻结量减
                // type=3可卖量加
                // type=4可卖量减
                pvOrderMapper.insertProductLogByUserId(
                        pvPossessionGoods.getUserId(),
                        buyorderid,
                        null,
                        pvPossessionGoods.getId(),
                        pvPossessionGoods.getProductId(),
                        pvPossessionGoods.getProductName(),
                        pvPossessionGoods.getUserId() + "：上传上票数量：" + order.getDelistingNumber(),
                        currentTime,
                        order.getDelistingNumber(),
                        1
                );
                //1加2减
                Integer integer = pvOrderMapper.updatePByUIdAndPid(order.getProductId(), pvProductGl.getSellUserId(), order.getDelistingNumber(), 1);

            }
            message.setSuccess(true);
            message.setCode("200");
            message.setData(pvPossessionGoods);
            message.setMessage("上传商品数量成功");

        } catch (Exception e) {
            message.setCode("-1");
            message.setSuccess(false);
            message.setMessage("上传商品数量失败");
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            e.printStackTrace();
        }
        return message;
    }

    public Integer productOrder(PvOrder order, BigDecimal poundage, Integer types, BigDecimal num) {
        PvOrder pvOrder = new PvOrder();
        pvOrder.setPaymentId(order.getPaymentId());
        pvOrder.setSerialNumber(OrderNumGeneration.generateOrderId()); //生成订单号
        pvOrder.setListingOrderId(order.getListingOrderId());//挂单方委托单号
        if (1 == types) {
            pvOrder.setListingUserId(order.getListingUserId()); //挂单用户ID
            pvOrder.setDelistingUserId(order.getDelistingUserId());    //摘单用户ID
            pvOrder.setUserId(order.getDelistingUserId());
        } else {
            pvOrder.setListingUserId(order.getDelistingUserId()); //挂单用户ID
            pvOrder.setDelistingUserId(order.getListingUserId());    //摘单用户ID
            pvOrder.setUserId(order.getListingUserId());
            //平台服务费
            pvOrder.setPlatformFwf((order.getUnitPrice().multiply(num).multiply(BigDecimal.valueOf(0.02))).setScale(2, BigDecimal.ROUND_DOWN));
            //购物券
//            pvOrder.setGwj(order.getGwj());
            pvOrder.setGwj((order.getUnitPrice().multiply(num).multiply(BigDecimal.valueOf(0.018))).setScale(2, BigDecimal.ROUND_DOWN));
//            //仓储费
            pvOrder.setStorageFwf((order.getUnitPrice().multiply(num).multiply(BigDecimal.valueOf(0.035))).setScale(2, BigDecimal.ROUND_DOWN));
            //是否是释放订单
            pvOrder.setIsReleaseOrder(order.getIsReleaseOrder());

        }
        pvOrder.setDelistingNumber(num.intValue());    //摘单数量
        pvOrder.setUnitPrice(order.getUnitPrice());    //摘单单价
        pvOrder.setTotalAmount(order.getUnitPrice().multiply(num));    //摘单总价格
        pvOrder.setPurchaseMethod(1);    //摘牌
        pvOrder.setDelistingStatus(types);    //摘单方式1买
        pvOrder.setPaymentState(1);
        pvOrder.setProductId(order.getProductId());    //商品ID
        pvOrder.setProductName(order.getProductName());    //商品名称
        pvOrder.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));//创建时间
        pvOrder.setUpdatedAt(new Date());    //更新时间
        pvOrder.setPoundage(poundage);    //手续费
        pvOrder.setRemark(order.getRemark());


        pvOrderMapper.insert(pvOrder);

        return pvOrder.getId();
    }

    /**
     * @param orderid   订单id
     * @param userid    用户id
     * @param bsnum     商品编号
     * @param bsamount  商品数量
     * @param bsprice   商品价格
     * @param types     类型：1.买2.卖3.提货4.转让5.释放
     * @param dtype     数据类型:1.已释放2.未释放3.无效数据
     * @param profitNum 盈利
     */
    @Transactional(rollbackFor = Exception.class)
    public void addReleaeseBase(Integer orderid, Integer userid, Integer bsnum, Integer bsamount, BigDecimal bsprice, Integer types, Integer dtype, BigDecimal profitNum) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        PvReleaseBase base = new PvReleaseBase();
            base.setBsAmount(new BigDecimal(bsamount));
            base.setBsNum(String.valueOf(bsnum));
            base.setUserId(userid);
            base.setOrderId(String.valueOf(orderid));
            base.setBsPrice(bsprice);
            base.setTypes(types);
            String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            base.setCTime(currentTime);
            LambdaQueryWrapper<PvSystemConfig> queryWrapper=new LambdaQueryWrapper<>();
            queryWrapper.eq(PvSystemConfig::getName,String.valueOf(bsnum));
            PvSystemConfig systemConfig =pvSystemConfigMapper.selectOne(queryWrapper);
          /*  PvSystemConfig systemConfig =pvSystemConfigMapper.selectOne(new PvSystemConfig(){{
                setName(String.valueOf(bsnum));
            }});*/
            if(null==systemConfig){
                throw  new Exception("该商品未设置可卖时间");
            }
            base.setDType(dtype);
            if (1 == types) {//只有买入才可以卖
                Object holidayValue = redisTemplate.opsForValue().get(transferableTimeGetHolidayRedisKey);
                String sTime="";
                if(null==holidayValue){
                    sTime = getHoliday(Integer.valueOf(systemConfig.getContent())) + " 00:00:00";
                    //设置过期时间10个小时
                    redisTemplate.opsForValue().set(transferableTimeGetHolidayRedisKey,sTime, 10,TimeUnit.HOURS);
                }else{
                    sTime=(String)holidayValue;
                }
                base.setWSell(1);
                base.setSellProfit(profitNum);//买入订单盈利为0
                base.setPurchaseNum(BigDecimal.valueOf(bsamount));//买入:可卖数余额设定为买入数量
                base.setSTime(sTime);
            } else if (7 == types) {
                base.setWSell(0);
                base.setSellProfit(profitNum);//买入订单盈利为0
                base.setPurchaseNum(new BigDecimal(0));//买入:可卖数余额设定为买入数量
                base.setSTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00");
            } else {
                base.setWSell(0);
                base.setSellProfit(profitNum);
                base.setPurchaseNum(BigDecimal.valueOf(0));//卖出:可卖数月设定为0
            }
            pvReleaseBaseMapper.insert(base);

    }
    public void goodsNumLog(PvOrder order, PvPossessionGoods pvPossessionGoods, Integer orderid, Integer type) {
        PvPossessionGoodsLog pvPossessionGoodsLog = new PvPossessionGoodsLog();
        pvPossessionGoodsLog.setCreateTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        pvPossessionGoodsLog.setUpdatedAt(new Date());
        pvPossessionGoodsLog.setGoodsId(pvPossessionGoods.getId());
        pvPossessionGoodsLog.setProductName(order.getProductName());
        pvPossessionGoodsLog.setProductId(order.getProductId());
        pvPossessionGoodsLog.setRemark(order.getDelistingUserId() + "：购买了" + order.getDelistingNumber());
        pvPossessionGoodsLog.setUserId(order.getDelistingUserId());
        if (1 == type) {
            //变化之前可卖量
            pvPossessionGoodsLog.setBeforeNumber(BigDecimal.valueOf(0));
            //变化之后可卖量
            pvPossessionGoodsLog.setAfterNumber(BigDecimal.valueOf(0));
            //变化量
            pvPossessionGoodsLog.setChangeNumber(BigDecimal.valueOf(order.getDelistingNumber()));
            //变化之前冻结量
            pvPossessionGoodsLog.setBeforFrozenNumber(BigDecimal.valueOf(0));
            //变化之后冻结量
            pvPossessionGoodsLog.setAfterFrozenNumber(BigDecimal.valueOf(order.getDelistingNumber()));
        }
        if (2 == type) {
            //变化之前可卖量
            pvPossessionGoodsLog.setBeforeNumber(pvPossessionGoods.getCansellNumber());
            //变化之后可卖量
            pvPossessionGoodsLog.setAfterNumber(pvPossessionGoods.getCansellNumber());
            //变化量
            pvPossessionGoodsLog.setChangeNumber(BigDecimal.valueOf(order.getDelistingNumber()));
            //变化之前冻结量
            pvPossessionGoodsLog.setBeforFrozenNumber(pvPossessionGoods.getPossessNumber().subtract(BigDecimal.valueOf(order.getDelistingNumber())));
            //变化之后冻结量
            pvPossessionGoodsLog.setAfterFrozenNumber(pvPossessionGoods.getPossessNumber());
        }
        pvPossessionGoodsLog.setEntrustOrderId(order.getListingOrderId());
        pvPossessionGoodsLog.setOrderId(orderid);
        pvPossessionGoodsLogMapper.insert(pvPossessionGoodsLog);
    }
    @Override
    public String getHoliday(Integer days) throws Exception {
        Date date = new Date();
        Calendar instance = Calendar.getInstance();
        instance.setTime(date);
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String cuurentDate = df.format(instance.getTime());
        //打印当前日期
        System.err.println(cuurentDate);
        int i = 0;//累计工作日的天数
        int t = days;//T+5的天数(设计的T+几)
        int accumulatedDays = 0;//T+5个工作日的累计天数
        while (true) {
//            System.err.println(cuurentDate);
            //根据当前的日期在数据库中查询是否为节假日
            LambdaQueryWrapper<PvHoliday> queryWrapper=new LambdaQueryWrapper<>();
            queryWrapper.eq(PvHoliday::getHoliday,cuurentDate);
            List<PvHoliday> select = pvHolidayMapper.selectList(queryWrapper);
            accumulatedDays++;
            //如果为工作日，那么累计工作日
            if (null == select || select.size() == 0) {
                i = i + 1;
            }
            instance.add(Calendar.DATE, 1);
            cuurentDate = df.format(instance.getTime());
            //如果累加工作日等于T+几的工作日就跳出循环
            if (i == t) {
                break;
            }
            Thread.sleep(100);
        }
//        System.err.println("总共天数：" + accumulatedDays);
//        System.err.println("T+5之后的日期：" + cuurentDate);
//        System.err.println("总共工作日：" + i);

        while (true) {
            LambdaQueryWrapper<PvHoliday> queryWrapper=new LambdaQueryWrapper<>();
            queryWrapper.eq(PvHoliday::getHoliday,cuurentDate);
            List<PvHoliday> select = pvHolidayMapper.selectList(queryWrapper);
            if (null == select || select.size() <= 0) {
                break;
            } else {
                instance.add(Calendar.DATE, 1);
                cuurentDate = df.format(instance.getTime());
            }
        }
//        System.err.println("T+5之后的工作日时间：" + cuurentDate);
        return cuurentDate;
    }

    /**
     * 买卖交易记录
     * @param pvBuySellOrderParam
     * @return
     */
    @Override
    public BusinessMessage selectAllTradeDetail(PvBuySellOrderParam pvBuySellOrderParam) {
        BusinessMessage message = new BusinessMessage();
        try {
            PvBuySellOrder pvBuySellOrder=new PvBuySellOrder();
            BeanUtil.copyProperties(pvBuySellOrderParam,pvBuySellOrder);
            if (null != pvBuySellOrderParam.getBeginTime() && null != pvBuySellOrderParam.getEndTime()) {
                Map<String, String> map = new HashMap<>(16);
                map=DateUtils.converTime(pvBuySellOrderParam.getBeginTime() , pvBuySellOrderParam.getEndTime());
                pvBuySellOrder.setBegin(map.get("begin"));
                pvBuySellOrder.setEnd(map.get("end"));
            }

            Page page= PageFactory.defaultPage();
            PageHelper.startPage((int)page.getCurrent(),(int)page.getSize());
            List<Map<String, Object>> resultList = patformMapper.selectAllTradeDetail(pvBuySellOrder);
            Map<Object, Object> resultMap = new HashMap<>();
            BuySellSummary buySellSummary=patformMapper.tradeSummary(pvBuySellOrder);
            //微信合计
            Map<String,Object> sumWx=patformMapper.summaryWx(pvBuySellOrder);
            //支付宝合计
            Map<String,Object> sumZfb=patformMapper.summaryZfb(pvBuySellOrder);
            //合计银联支付合计
            Map<String,Object> sumUnionPay=patformMapper.summaryUnionPay(pvBuySellOrder);
            //平台余额合计
            Map<String,Object> sumWalletLog=patformMapper.sumWalletLog(pvBuySellOrder);
            if(buySellSummary==null){
                buySellSummary=new BuySellSummary();
            }
            //合计商品数量
            resultMap.put("sumProductNum",buySellSummary.getSumProductNum());
            //合计实时价
            resultMap.put("sumSSPrice", buySellSummary.getSumSSPrice());
            //合计总额
            resultMap.put("sumTotal", buySellSummary.getSumTotal());
            //合计手续费
            resultMap.put("sumSXF", buySellSummary.getSumSXF());
            //合计平台服务费
            resultMap.put("platformFWF", buySellSummary.getPlatformFWF());
            //合计仓储费
            resultMap.put("sumCCF", buySellSummary.getSumCCF());
            //合计购物券
            resultMap.put("sumGWJ", buySellSummary.getSumGWJ());
            //合计商品奖励
            resultMap.put("sumSPJL", buySellSummary.getSumSPJL());
            //微信支付合计
            resultMap.put("sumWx", sumWx.get("sumWx"));
            //支付宝合计
            resultMap.put("sumZfb", sumZfb.get("sumZfb"));
            //合计银联支付
            resultMap.put("sumUnionPay", sumUnionPay.get("sumUnionPay"));
            //合计平台余额
            resultMap.put("sumWalletLog", sumWalletLog.get("sumWalletLog"));
            if (resultList == null || resultList.size() < 0) {
                message.setMessage(Status.fail);
                message.setSuccess(false);
                message.setCode(Status.failCode);
                return message;
            }
            PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(resultList);
            resultMap.put("pageInfo", pageInfo);
            message.setData(resultMap);
            message.setSuccess(true);
            message.setMessage(Status.success);
            message.setCode(Status.successCode);
            return message;
        } catch (Exception e) {
            message.setMessage(Status.fail);
            message.setSuccess(false);
            message.setCode(Status.failCode);
            e.printStackTrace();
        }
        return message;
    }

    /**
     * 促销活动记录
     * @param pvBuySellOrderParam
     * @return
     */
    @Override
    public BusinessMessage activitiesList(PvBuySellOrderParam pvBuySellOrderParam) {
        BusinessMessage message = new BusinessMessage();
        try {
            PvBuySellOrder pvBuySellOrder=new PvBuySellOrder();
            BeanUtil.copyProperties(pvBuySellOrderParam,pvBuySellOrder);
            PageHelper.startPage(pvBuySellOrderParam.getPageNo(),pvBuySellOrderParam.getPageSize());
            List<Map<String, Object>> resultList = pvOrderMapper.activitiesList(pvBuySellOrder);
            PageInfo<Map<String, Object>> map = new PageInfo<>(resultList);
            message.setData(map);
            message.setSuccess(true);
            message.setMessage(Status.success);
            message.setCode(Status.successCode);
            return message;
        } catch (Exception e) {
            message.setMessage(Status.fail);
            message.setSuccess(false);
            message.setCode(Status.failCode);
            e.printStackTrace();
        }
        return message;
    }
}
